package cn.com.controler.Article;

import cn.com.entity.Article;

import java.util.List;

public class ArticleDAO {

    //添加数据
    public int addarticle(Article article){
        String str = "insert into article values(null,?,null,?,?,?,0)";
        Object []arr = new Object[]{article.getArticleUserId(),article.getArticleTitle(),article.getArticleContent(),article.getArticlePublishTime()};
        return ArticleDAOTemplete.insertdata(str,arr);
    }

    //查询所有数据
    public List<Article> selectallarticle(){
        String str = "select *from article order by ArticleType desc";
        Object[] arr = new Object[]{};
        return ArticleDAOTemplete.selectdata(str,arr);
    }

    //根据id删除数据
    public int delarticleby(int id){
        String str = "delete from article where ArticleId = ?";
        Object []arr = new Object[]{id};
        return ArticleDAOTemplete.insertdata(str,arr);
    }
}
